/*
 * 杭州绿漫科技有限公司
 * Copyright (c) 16-6-22 上午11:34.
 */

package com.jams.goodox.entity;

import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.RelativeSizeSpan;

import java.io.Serializable;
import java.text.DecimalFormat;

/**
 * Created by jams on 2016/6/22.
 * ***
 * Tel: ***
 */

public class User implements Serializable {

    public static final String USER_TYPE_COMPANY = "107";
    public static final String USER_TYPE_PERSON = "103";

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    private String loginName;//登录名
    private String nickName;//昵称
    private String userName;//真实姓名
    private String headPicName;//头像
    private String birthday;//生日
    private String intCnt;//积分
    private String mobileNum;//手机号码
    private String sex;//性别 1 男  2女
    private String userId;//用户id
    private boolean isCertification;//身份认证
    private String userType;//用户类型   //1:业主，2家属，3：租客
    private int redPacketNum;//红包数量
    private String flag;
    private String isSign;
    private String alias;

    private String represent;//0 未关联企业 1 关联企业 2关联企业并且是授权用户 3待审核 4拒绝

    private String isExamine;//0待确认1已确认2未通过（房产是否审核通过）

    private boolean isSetPayPwd;
    private String money;

    private String enterpriseId;//企业id
    private String enterpriseName;//企业名称
    private String enterpriseAddress;//企业地址
    private String enterpriseHouseId;//企业房号id
    private Address address;//默认地址
    private String id;//用户id
    private int maillistStatus;//1可见 0不可见
    private String enterpriseAdminId;//企业账号的用户id
    private int noticeCnt;//首页的未读消息数量
    private String communityName;//***名称

    public String getEnterpriseAdminId() {
        return enterpriseAdminId;
    }

    public void setEnterpriseAdminId(String enterpriseAdminId) {
        this.enterpriseAdminId = enterpriseAdminId;
    }



    public boolean isSetPayPwd() {
        return isSetPayPwd;
    }

    public void setSetPayPwd(boolean setPayPwd) {
        isSetPayPwd = setPayPwd;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    public String getHeadPicName() {
        return headPicName;
    }

    public void setHeadPicName(String headPicName) {
        this.headPicName = headPicName;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public String getIsSign() {
        return isSign;
    }

    public void setIsSign(String isSign) {
        this.isSign = isSign;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public boolean isCertification() {
        return isCertification;
    }

    public void setCertification(boolean certification) {
        isCertification = certification;
    }

    public String getSexStr() {
        if (null == sex)
            return "";
        if (sex.equalsIgnoreCase("1")) {
            return "男";
        } else if (sex.equalsIgnoreCase("2")) {
            return "女";
        } else if (sex.equalsIgnoreCase("")) {
            return "";
        }
        return "";
    }

    public String getUserTypeStr() {
        if (userType.equalsIgnoreCase("1")) {
            return "业主";
        } else if (userType.equalsIgnoreCase("2")) {
            return "家属";
        } else if (userType.equalsIgnoreCase("3")) {
            return "租户";
        }
        return "租户";
    }


    public Address getAddress() {
        return address == null ? new Address() : address;
    }

    public void setAddress(Address data) {
        this.address = data;
    }

    public static boolean isAddressExit(Address mAddress){
        return mAddress!=null&& !TextUtils.isEmpty(mAddress.getAddressDetail());
    }

    public boolean isUserAddressExit(){
        return isAddressExit(address);
    }

    public String getBirthDay() {
        return birthday;
    }

    public void setBirthDay(String birthDay) {
        this.birthday = birthDay;
    }

    public String getPortraitUrl() {
        return headPicName;
    }

    public void setPortraitUrl(String headPicName) {
        this.headPicName = headPicName;
    }

    public String getIntCnt() {
        return intCnt;
    }

    public void setIntCnt(String intCnt) {
        this.intCnt = intCnt;
    }

    public String getMobileNum() {
        return mobileNum;
    }

    public void setMobileNum(String mobileNum) {
        this.mobileNum = mobileNum;
    }

    public String getName() {
        return userName;
    }

    public void setName(String name) {
        this.userName = name;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public int getRedPacketNum() {
        return redPacketNum;
    }

    public void setRedPacketNum(int redPacketNum) {
        this.redPacketNum = redPacketNum;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String id) {
        this.userId = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getIsExamine() {
        return isExamine;
    }

    public void setIsExamine(String isExamine) {
        this.isExamine = isExamine;
    }

    public String getEnterpriseId() {
        if (enterpriseId == null) {
            return "";
        }
        return enterpriseId;
    }

    public void setEnterpriseId(String enterpriseId) {
        this.enterpriseId = enterpriseId;
    }

    public String getEnterpriseName() {
        return enterpriseName;
    }

    public void setEnterpriseName(String enterpriseName) {
        this.enterpriseName = enterpriseName;
    }

    public String getRepresent() {
        if (represent == null) {
            return "";
        }
        return represent;
    }

    public void setRepresent(String represent) {
        this.represent = represent;
    }

    public String getEnterpriseHouseId() {
        return enterpriseHouseId;
    }

    public void setEnterpriseHouseId(String enterpriseHouseId) {
        this.enterpriseHouseId = enterpriseHouseId;
    }

    /**
     * 显示不同大小的字符串
     *
     * @param unit 單位
     * @param text
     * @return
     */
    public static SpannableStringBuilder getPriceStyle(Double text, String unit) {
        String price;
        SpannableStringBuilder spannable;
        price = getPriceString(text);
        String priceStr = "¥" + price + unit;
        spannable = new SpannableStringBuilder(priceStr);//用于可变字符串
        CharacterStyle span_1 = new RelativeSizeSpan(1.5f);
        spannable.setSpan(span_1, 1, String.valueOf(text.intValue()).length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return spannable;
    }

    public String getEnterpriseAddress() {
        return enterpriseAddress;
    }

    public void setEnterpriseAddress(String enterpriseAddress) {
        this.enterpriseAddress = enterpriseAddress;
    }

    //新的获取价格方法
    public static String getPriceString(Double price) {
        if (price == null) {
            return "0.00";
        }
//        if ((int) price.doubleValue() == price) {
//            return String.valueOf((int) price.doubleValue());
//        }
        DecimalFormat df = new DecimalFormat("######0.00");
        return df.format(price);
    }

    public boolean isCompanyAccount() {
        return USER_TYPE_COMPANY.equalsIgnoreCase(userType);
    }


    public int getMaillistStatus () {
        return maillistStatus;
    }

    public void setMaillistStatus(int maillistStatus) {
        this.maillistStatus = maillistStatus ;
    }

    public int getNoticeCnt() {
        return noticeCnt;
    }

    public void setNoticeCnt(int noticeCnt) {
        this.noticeCnt = noticeCnt;
    }

    public String getCommunityName() {
        return communityName;
    }

    public void setCommunityName(String communityName) {
        this.communityName = communityName;
    }
}
